package ru.spb.osll.myfit.client.widget;

import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.TextBox;

import ru.spb.osll.myfit.common.Table;

public class MyFitTableWidget extends FlexTableWidget {

	public MyFitTableWidget(GWTWidgetFactory gwtWidgetFactory, Table table) {
		super(gwtWidgetFactory, table);
	}

	@Override
	protected void tuneMenu() {
		m_addCellItem.setVisible(true);
//		m_deleteCellItem.setVisible(true);
	}

	@Override
	protected void setReadOnly(boolean isReadOnly) {
	  int rowCount = m_flexTable.getRowCount();
    
		for (int i = 0; i < rowCount; i++) {
			HorizontalPanel panel = (HorizontalPanel) m_flexTable.getWidget(i, 0);
			int widgetCount = panel.getWidgetCount();
			for (int j = 0; j < widgetCount; j++)
				try {
					((TextBox) panel.getWidget(j)).setReadOnly(isReadOnly);
				} catch (Exception ex) {
				}
		}
	}

}
